<!DOCTYPE html>
<html class="ui-page-login">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
    <link href="../css/login_reg.css" rel="stylesheet" type="text/css">
    <style>
        * {
            margin: 0;
        }
        #reg .logreg-input-code{
        	width: 80%;
        }
        #already {
            font-size: 12px!important; 
            color: #7b7b7b!important; 
            text-decoration: none;
        }
        body{
				background:#EEF6FF!important;
				position: absolute;
				width: 100%;
				top: 10%;
			}
    </style>
</head>

<body>
    <div id="reg">
        <div class="logreg">
            <!--<img src="../images/login_reg1.png" class="logreg-banner logreg-wrap"/>-->
            <div class="logreg-input-frame logreg-wrap">
                <input type="" name="" id="mobileText" value="" placeholder="请输入您的手机号码" class="logreg-input" />
                <div class="logreg-input-code clearfix posir">
                    <input type="text" name="" id="vcodeText" value="" maxlength="20" placeholder="填写验证码" class="logreg-input fl" onKeyUp="value=value.replace(/[^\w\.\/]/ig,'')" />
                    <div class="line"></div>
                    <input type="button" name="" id="vcodeBtn" value="获取验证码" class="logreg-input reg-button-code fr" />
                </div>
                <input type="password" name="" id="pwdText" value="" placeholder="输入密码" class="logreg-input" />
                <input type="password" name="" id="rpwdText" value="" placeholder="确认密码" class="logreg-input" />
                <div class="login-a-frame clearfix">
                    <a id="already" href="login.html" class="fl">已有账号</a>
                </div>
                <button type="button" name="findBtn" id="findBtn" class="logreg-input buttom animated fadeInUp" />找回密码</button>
            </div>
            <!--div class="logreg-line">Copyright © 2018 All Rights Reserved</div-->
        </div>
    </div>
    <script src="../js/mui.min.js"></script>
    <script src="../js/jquery-1.8.3.min.js"></script>
    <script src="../js/verification.js"></script>
    <script src="../js/app.js"></script>
    <script>
        (function($, doc) {
            $.init();
            $.plusReady(function() {
                //设置只支持竖屏幕显示
                plus.screen.lockOrientation("portrait-primary");

                var mobileText = doc.getElementById('mobileText');
                var vcodeText = doc.getElementById('vcodeText');
                var pwdText = doc.getElementById('pwdText');
                var rpwdText = doc.getElementById('rpwdText');
                var vcodeBtn = doc.getElementById('vcodeBtn');
                var findBtn = doc.getElementById('findBtn');
                //发送验证码
                vcodeBtn.addEventListener('tap', function(event) {
                    if (!verification.phone(mobileText.value, "mobileText")) return;

                    settime()

                    verification.code(mobileText.value, "vcodeBtn");
                });
                //注册
                var regBtnStatus = 0;
                findBtn.addEventListener('tap', function(event) {
                    if (regBtnStatus == 1) return;
                    regBtnStatus == 1;

                    if (!verification.phone(mobileText.value, "mobileText")) return;
                    if (!verification.vcode(vcodeText.value, "vcodeText")) return;
                    if (!verification.pwd(pwdText.value, "pwdText")) return;
                    if (!verification.rpwd(pwdText.value, rpwdText.value, "rpwdText")) return;
                    if (ismobile() == 0) {
                        apptype = 2
                    } else {
                        apptype = 1
                    }
                    var data = {
                        tel: mobileText.value, //注册手机号
                        code: vcodeText.value, //验证码
                        pwd: pwdText.value,
                        appType: apptype
                    }; 

                    mui.post(Apiurl+'index/forget', data, function(result) {
                        if (result.status == 200) {
                            mui.openWindow({
                                url: 'login.html',
                                id: 'loging',
                                preload: true,
                                show: {
                                    aniShow: 'pop-in'
                                },
                                styles: {
                                    popGesture: 'hide'
                                },
                                waiting: {
                                    autoShow: false
                                }
                            });
                            mui.toast("找回密码成功");

                        } else if (result.status == 202) {
                            mui.toast(result.errmsg);
                        } else if (result.status == 201) {
                            mui.toast(result.errmsg);
                        }else if (result.status == 203) {
                            mui.toast(result.errmsg);
                        }
                    }, 'json');
                });
            });
        }(mui, document));
        var countdown = 60;

        function settime() {
            if (countdown == 0) {
                document.getElementById('vcodeBtn').removeAttribute("disabled");
                document.getElementById('vcodeBtn').value = "获取验证码";
                countdown = 60;
                return;
            } else {
                document.getElementById('vcodeBtn').setAttribute("disabled", true);
                document.getElementById('vcodeBtn').value = "重新发送(" + countdown + ")";
                countdown--;
            }
            setTimeout(function() {
                settime()
            }, 1000)
        }
    </script>
</body>

</html>